package com.hekang.fragmentdemo;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;

/**
 * Created by hekang on 2018/9/9.
 */

public class FragmentValues1 extends Fragment {

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragmnet1, container, false);
        //初始化控件
        final EditText editText = view.findViewById(R.id.et_values);
        Button button = view.findViewById(R.id.but_set);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //点击按钮
                FragmentValues2 fragmentValues2 = new FragmentValues2();
                Bundle bundle = new Bundle();
                bundle.putString("msg", editText.getText().toString());
                fragmentValues2.setArguments(bundle);
                getFragmentManager().beginTransaction().replace(R.id.container,fragmentValues2).commit();
            }
        });
        return view;
    }
}
